using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.Page;
using Microsoft.Phone.Controls;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class QQFriendsListItem : UserControl, MMItemCtrl
	{
		public static bool isFromQQMsgPulgin;
		public static DependencyProperty ListItemProperty;
		internal EmojiText NickName;
		internal Image HeadImage;
		internal StackPanel AddArea;
		internal Image addFlag;
		internal TextBlock tips;
		private bool _contentLoaded;
		public event ListItemClick ItemClick;
		public QFriend ItemObject
		{
			get
			{
				return (QFriend)base.GetValue(QQFriendsListItem.ListItemProperty);
			}
			set
			{
				base.SetValue(QQFriendsListItem.ListItemProperty, value);
			}
		}
		public QQFriendsListItem()
		{
			this.InitializeComponent();
			base.SetValue(TiltEffect.IsTiltEnabledProperty, true);
		}
		private void QQFriendsListItem_MouseLeftButtonUp(object sender, RoutedEventArgs e)
		{
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.ItemObject);
			}
		}
		public void Refresh()
		{
			this.RefreshItem(this.ItemObject);
			this.HeadImage.set_Source(HeadImgMgr.getHeadImage(this.ItemObject));
		}
		private void RefreshItem(QFriend item)
		{
			if (item == null)
			{
				return;
			}
			string text;
			if (!string.IsNullOrEmpty(item.strQQRemarkName))
			{
				text = item.strQQRemarkName;
			}
			else
			{
				if (!string.IsNullOrEmpty(item.strQQNickName))
				{
					text = item.strQQNickName;
				}
				else
				{
					text = item.nQQ.ToString();
				}
			}
			this.NickName.Text = text;
			this.HeadImage.set_Source(HeadImgMgr.getCacheHeadImage(this.ItemObject));
			if (QQFriendsListItem.isFromQQMsgPulgin)
			{
				this.tips.set_Visibility(1);
				this.addFlag.set_Visibility(1);
				return;
			}
			if (item.nWeixinStatus == 1u)
			{
				this.tips.set_Text(strings.QQFriend_Add);
				this.tips.set_Foreground(MMTheme.GetInstance().SNS_MSGPAGE_TIME_BRUSH);
				this.tips.set_Visibility(0);
				return;
			}
			if (item.nWeixinStatus == 0u)
			{
				this.tips.set_Text(strings.Friend_Invite);
				this.tips.set_Foreground(MMTheme.GetInstance().COMMON_BRUSH);
				this.tips.set_Visibility(1);
				return;
			}
			this.tips.set_Text(strings.QQFriend_Added);
			this.tips.set_Foreground(MMTheme.GetInstance().SNS_MSGPAGE_TIME_BRUSH);
			this.addFlag.set_Visibility(1);
		}
		static QQFriendsListItem()
		{
			QQFriendsListItem.isFromQQMsgPulgin = false;
			QQFriendsListItem.ListItemProperty = DependencyProperty.Register("ItemObject", typeof(QFriend), typeof(QQFriendsListItem), new PropertyMetadata(null, new PropertyChangedCallback(QQFriendsListItem.OnItemPropertyChanged)));
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == QQFriendsListItem.ListItemProperty)
			{
				(dependencyObject_0 as QQFriendsListItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			this.RefreshItem(dependencyPropertyChangedEventArgs_0.get_NewValue() as QFriend);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Common/QQInfo/UI/QQFriendsListItem.xaml", 2));
			this.NickName = (EmojiText)base.FindName("NickName");
			this.HeadImage = (Image)base.FindName("HeadImage");
			this.AddArea = (StackPanel)base.FindName("AddArea");
			this.addFlag = (Image)base.FindName("addFlag");
			this.tips = (TextBlock)base.FindName("tips");
		}
	}
}
